<?php

namespace App\Http\Controllers\Home;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use DB;
class IndexController extends Controller
{
     public function index()
     {
        $pic = DB::table('home_pic as h')
            -> select('h.pic')
            -> get();
        $picNum = DB::table('home_pic')
             -> count();
        // dd($picNum);
        $itv = DB::table('itv') -> orderBy('money','desc') -> get();

        $rexiao = DB::table('goodszhuda') ->where('leixing','rexiao') -> select() ->get();
        foreach($rexiao as $row)
        {
            $row -> lid = $row -> gid;
            $row -> gid = DB::table('goods') -> where('gid',$row->gid) ->first() -> gname;
        }

        $xinpin = DB::table('goodszhuda') ->where('leixing','xinpin') -> select() ->get();
        foreach($xinpin as $row)
        {
            $row -> lid = $row -> gid;
            $row -> gid = DB::table('goods') -> where('gid',$row->gid) ->first() -> gname;
        }

        $jingpin = DB::table('goodszhuda') ->where('leixing','jingpin') -> select() ->get();
        foreach($jingpin as $row)
        {
            $row -> lid = $row -> gid;
            $row -> gid = DB::table('goods') -> where('gid',$row->gid) ->first() -> gname;
        }

       


        return view('home.index.index',['title' =>'主页','pic' => $pic,'itv' => $itv,'picNum' => $picNum,'rexiao'=>$rexiao,'jingpin'=>$jingpin,'xinpin'=>$xinpin]);
     }

     public function joinme()
     {
          return view('home.joinme.index',['title' => '加入我们']);
     }

}

